//
//  UIView+YY.h
//  YiYunSTP
//
//  Created by apple on 2019/3/21.
//  Copyright © 2019年 yiyuniot. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN
#pragma mark --<Base>
@interface UIView (YY)
/**
 * Shortcut for frame.origin.x.
 *
 * Sets frame.origin.x = left
 */
@property (nonatomic) CGFloat x;

/**
 * Shortcut for frame.origin.y
 *
 * Sets frame.origin.y = top
 */
@property (nonatomic) CGFloat y;

/**
 * Shortcut for frame.origin.x + frame.size.width
 *
 * Sets frame.origin.x = right - frame.size.width
 */
@property (nonatomic) CGFloat maxX;

/**
 * CGRectGetMaxY(self.frame);
 */
@property (nonatomic) CGFloat maxY;

/**
 * Shortcut for frame.size.width
 *
 * Sets frame.size.width = width
 */
@property (nonatomic) CGFloat width;

/**
 * Shortcut for frame.size.height
 *
 * Sets frame.size.height = height
 */
@property (nonatomic) CGFloat height;

/**
 * Shortcut for center.x
 *
 * Sets center.x = centerX
 */
@property (nonatomic) CGFloat centerX;

/**
 * Shortcut for center.y
 *
 * Sets center.y = centerY
 */
@property (nonatomic) CGFloat centerY;

/**
 * Shortcut for frame.origin
 */
@property (nonatomic) CGPoint origin;

/**
 * Shortcut for frame.size
 */
@property (nonatomic) CGSize size;

@end

#pragma mark --<Shadow>
@interface UIView (Shadow)
/** 绘制阴影的角度 */
@property (nonatomic, assign) CGFloat yy_ShadowRadius;
/** 绘制阴影的颜色,但是必须添加在shadowRadius前面，否则不起作用 */
@property (nonatomic, strong) UIColor *yy_ShadowColor;
/** 绘制阴影的角度 */
-(void)yy_DrawShadowWithRadius:(CGFloat)radius;
-(void)yy_drawCornerRadius:(CGFloat)cornerRadius borderColor:(UIColor *)borderColor;
/** 绘制某几个方向圆角、边框、边框颜色 */
- (void)yy_drawCornerRadius:(CGFloat)cornerRadius
                borderColor:(UIColor *)borderColor
          byRoundingCorners:(UIRectCorner)corners;
/** 绘制几个方向的圆角*/
- (void)yy_drawCornerRadius:(CGFloat)radius byRoundingCorners:(UIRectCorner)corners;

#pragma mark --<cornerRadius>
- (void)yy_addCornerRadius:(CGFloat)radius borderWidth:(CGFloat)borderWidth backgroundColor:(UIColor*)backgroundColor borderColor:(UIColor *)borderColor;

/** 绘制虚线 */
- (void)yy_drawDashLineColor:(UIColor *)lineColor lineDashPattern:(NSArray<NSNumber *> *)lineDashPattern lineRect:(CGRect)lineRect isHorizonal:(BOOL)isHorizonal;
@end

@interface UIView (Present)
/** 找到自己的vc */
- (UIViewController *)viewController;

-(void)removeAllSubViews;
@end


typedef NS_OPTIONS(NSUInteger, QMUIViewBorderPosition) {
    QMUIViewBorderPositionNone      = 0,
    QMUIViewBorderPositionTop       = 1 << 0,
    QMUIViewBorderPositionLeft      = 1 << 1,
    QMUIViewBorderPositionBottom    = 1 << 2,
    QMUIViewBorderPositionRight     = 1 << 3
};

@interface UIView (Border)

/// 设置边框类型，支持组合，例如：`borderPosition = QMUIViewBorderPositionTop|QMUIViewBorderPositionBottom`。默认为 QMUIViewBorderPositionNone。
@property(nonatomic, assign) QMUIViewBorderPosition yy_borderPosition;

/// 边框的大小，默认为PixelOne。请注意修改 qmui_borderPosition 的值以将边框显示出来。
@property(nonatomic, assign) CGFloat yy_borderWidth;

/// 边框的颜色，默认为UIColorSeparator。请注意修改 qmui_borderPosition 的值以将边框显示出来。
@property(nullable, nonatomic, strong) UIColor *yy_borderColor;

/// border的layer
@property(nullable, nonatomic, strong, readonly) CAShapeLayer *yy_borderLayer;

@end


NS_ASSUME_NONNULL_END
